function showTelInfo(id) {
	var url = "/IMS/convenienceTel/showTelInfo.ht?convenId=" + id;
	$.go(url, {
		dataType : 'html',
		beforeSend : function() {
			showProccessBar();
		},
		error : function() {
			hideProccessBar();
		},
		success : function(data, textStatus) {
			replaceDocument(url, data);
		}
	});
}

function searchSubmit() {
	// var communityId = $("#select2-communityId-container").text();
	// if (communityId == '请选择小区') {
	// _alert("请选择小区");
	// } else {
	$.submit($('#frm'), {
		dataType : 'html',
		beforeSend : function() {
			showProccessBar();
		},
		error : function() {
			hideProccessBar();
		},
		success : function(data, textStatus) {
			var url = $('#frm').attr('action');
			replaceDocument(url, data);
		}
	});
	// }
}

$(function() {
	$("#communityId").select2({
		placeholder : '请选择小区',
		language : "zh-CN",
		allowClear : true,
		ajax : {
			url : '/IMS/select/getCommunityList.ht',
			dataType : 'json',
			delay : 250,
			data : function(param) {
				return {
					search : param.term,
					page : param.page || 1,
					showAllItem : true
				};
			},
			processResults : function(data, param) {
				param.page = data.pageNum;
				return {
					results : data.list,
					pagination : {
						more : data.hasNextPage
					}
				};
			}
		},
		escapeMarkup : function(markup) {
			return markup;
		},
		templateResult : formatRepo,
		templateSelection : function(obj) {
			$("#ht_cid").val(obj.id || '');
			return obj.name || obj.text;
		}
	});
});

function toAdd() {
	var cid = $("#ht_cid").val() || undefined;
	var url = "/IMS/convenienceTel/showTelInfo.ht";
	$.go(url, {
		dataType : 'html',
		data : {
			cid : cid
		},
		beforeSend : function() {
			showProccessBar();
		},
		error : function() {
			hideProccessBar();
		},
		success : function(data, textStatus) {
			replaceDocument(url, data);
		}
	});
}